import { get, request } from '../ajax'
import { getAjaxBaseUrl } from '../handler'
import type { STORAGE_MODES } from '@/enum/modules/indicator'

const baseUrl = getAjaxBaseUrl('/consumption', '/energy')

/** 用能单元统计 */
export function getConsumptionUnitStatistics(params: {
  pointId: number
  timeType: STORAGE_MODES
  time: string
}) {
  return get<any>(`${baseUrl}/energy/statistics`, params)
}

/** 能耗汇总统计 */
export function getConsumptionSummaryStatistics(params: {
  pointId: number
  startTime: string
  endTime: string
  all: boolean
  isIncludeSelf: boolean
}) {
  return get<any>(`${baseUrl}/energy/summary`, params)
}

/** 导出能耗汇总统计 */
export function exportConsumptionSummaryStatistics(data: {
  pointId: number
  startTime: string
  endTime: string
  all: boolean
  isIncludeSelf: boolean
}) {
  return request({
    url: `${baseUrl}/energy/export`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}
